using System.IO;
using NMock2;

namespace NDomain.Tests
{
    public class AlwaysSameObjectMatcher<T> : Matcher where T : class
    {
        private object _object;

        public override void DescribeTo(TextWriter writer)
        {
            writer.Write("Always same object of type {0}", typeof(T).Name);
        }

        public override bool Matches(object o)
        {
            if (!(o is T) || (_object != null && !ReferenceEquals(_object, o)))
                return false;

            _object = o;

            return true;
        }
    }
}